\doxysection{x\+Queue\+Overwrite\+From\+ISR }
\hypertarget{group__x_queue_overwrite_from_i_s_r}{}\label{group__x_queue_overwrite_from_i_s_r}\index{xQueueOverwriteFromISR@{xQueueOverwriteFromISR}}
queue. h 
\begin{DoxyPre}
 BaseType\_t xQueueOverwriteFromISR(                               QueueHandle\_t xQueue,                               const void * pvItemToQueue,                               BaseType\_t *pxHigherPriorityTaskWoken                          );
   \end{DoxyPre}


A version of x\+Queue\+Overwrite() that can be used in an interrupt service routine (ISR).

Only for use with queues that can hold a single item -\/ so the queue is either empty or full.

Post an item on a queue. If the queue is already full then overwrite the value held in the queue. The item is queued by copy, not by reference.


\begin{DoxyParams}{Parameters}
{\em x\+Queue} & The handle to the queue on which the item is to be posted.\\
\hline
{\em pv\+Item\+To\+Queue} & A pointer to the item that is to be placed on the queue. The size of the items the queue will hold was defined when the queue was created, so this many bytes will be copied from pv\+Item\+To\+Queue into the queue storage area.\\
\hline
{\em px\+Higher\+Priority\+Task\+Woken} & x\+Queue\+Overwrite\+From\+ISR() will set \texorpdfstring{$\ast$}{*}px\+Higher\+Priority\+Task\+Woken to pd\+TRUE if sending to the queue caused a task to unblock, and the unblocked task has a priority higher than the currently running task. If x\+Queue\+Overwrite\+From\+ISR() sets this value to pd\+TRUE then a context switch should be requested before the interrupt is exited.\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
x\+Queue\+Overwrite\+From\+ISR() is a macro that calls x\+Queue\+Generic\+Send\+From\+ISR(), and therefore has the same return values as x\+Queue\+Send\+To\+Front\+From\+ISR(). However, pd\+PASS is the only value that can be returned because x\+Queue\+Overwrite\+From\+ISR() will write to the queue even when the queue is already full.
\end{DoxyReturn}
Example usage\+: 
\begin{DoxyPre}

 QueueHandle\_t xQueue;

 void vFunction( void *pvParameters )
 \{
    // Create a queue to hold one uint32\_t value.  It is strongly
    // recommended *not* to use xQueueOverwriteFromISR() on queues that can
    // contain more than one value, and doing so will trigger an assertion
    // if configASSERT() is defined.
    xQueue = xQueueCreate( 1, sizeof( uint32\_t ) );
\}

void vAnInterruptHandler( void )
\{
// xHigherPriorityTaskWoken must be set to pdFALSE before it is used.
BaseType\_t xHigherPriorityTaskWoken = pdFALSE;
uint32\_t ulVarToSend, ulValReceived;

    // Write the value 10 to the queue using xQueueOverwriteFromISR().
    ulVarToSend = 10;
    xQueueOverwriteFromISR( xQueue, \&ulVarToSend, \&xHigherPriorityTaskWoken );

    // The queue is full, but calling xQueueOverwriteFromISR() again will still
    // pass because the value held in the queue will be overwritten with the
    // new value.
    ulVarToSend = 100;
    xQueueOverwriteFromISR( xQueue, \&ulVarToSend, \&xHigherPriorityTaskWoken );

    // Reading from the queue will now return 100.

    // ...

    if( xHigherPrioritytaskWoken == pdTRUE )
    \{
        // Writing to the queue caused a task to unblock and the unblocked task
        // has a priority higher than or equal to the priority of the currently
        // executing task (the task this interrupt interrupted).  Perform a context
        // switch so this interrupt returns directly to the unblocked task.
        portYIELD\_FROM\_ISR(); // or portEND\_SWITCHING\_ISR() depending on the port.
    \}
\}
 \end{DoxyPre}
 